#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int cToi(char ch)
{
    return ch - '0';
}

string addBinary(string a, string b) {
    int i = a.size() - 1, j = b.size() - 1;
    int c = 0;
    string ret;

    while (i >= 0 && j >= 0)
    {
        int tmp = (cToi(a[i]) + cToi(b[j]) + c ) % 2;
        c = (cToi(a[i]) + cToi(b[j]) + c ) / 2;
        ret += (tmp + '0');
        i--;
        j--;
    }

    while (i >= 0)
    {
        int tmp = (cToi(a[i]) + (c + '0')) % 2;
        c = (cToi(a[i])  + c ) / 2;
        ret += (tmp + '0');
        i--;
    }
    while (j >= 0)
    {
        int tmp = ( cToi(b[j]) + (c + '0')) % 2;
        c = (cToi(b[j]) + c) / 2;
        ret += (tmp + '0');
        j--;
    }

    if (c != 0)
    {
        ret += (c + '0');
    }

    string tmp;
    for (int i = ret.size() - 1; i >= 0; --i)
    {
        tmp += ret[i];
    }

    return tmp;
}



int main()
{
    std::cout << addBinary("11", "1");
	return 0;
}